package com.sloera.nowcoder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

/**
 * class com.sloera.nowcoder
 * user sloera
 * date 2022/2/24
 */
public class HJ19 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        final ArrayList<String> result = new ArrayList<>();
        final HashMap<String, Integer> count = new HashMap<>();
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            final String s = in.nextLine();
            if (!"".equals(s)) {
                handle(result, count, s);
            } else {
                break;
            }
        }
        // 倒序输出8个
        for (int i = Math.max(result.size() - 8, 0); i < result.size(); i++) {
            System.out.println(result.get(i) + " " + count.get(result.get(i)));
        }
    }

    private static void handle(ArrayList<String> result, HashMap<String, Integer> count, String s) {
        // 区分行号和路径
        final String[] split = s.split("\\s+");
        // 替换掉目录 和 超长的文件名
        String name = split[0].replaceAll(".*\\\\", "").replaceAll("^.*?(.{16})$", "$1") + " " + split[1];
        if (count.containsKey(name)) {
            count.put(name, count.get(name) + 1);
        } else {
            result.add(name);
            count.put(name, 1);
        }
        ;
    }

}